#include<iostream>
using namespace std;
int main() {
	int a, temp, sum;
	cin >> a;
	while (a) {
        int flag = 0;
        int num = a;
		sum = 0;
		while (num) {
			temp = num % 10;
			sum += temp;
			num /= 10;
		}
		if (!(sum % 4)){
            cout << a << endl;
            flag = 1;
        }
		if(flag)
            break;
	    a++;
    }

	return 0;
}